home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / BARNET / COMPILER / SATHER / !Sather / Library / Graphs / sa / abs_ugraph < prev    next >
Text File  |  1996-07-13  |  3KB  |  64 lines

  1. ---------------------------> Sather 1.1 source file <--------------------------
  2. -- Author: Benedict A. Gomes <gomes@icsi.berkeley.edu>
  3. -- COPYRIGHT NOTICE: This code is provided WITHOUT ANY WARRANTY
  4. -- and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
  5. -- LICENSE contained in the file: Sather/Doc/License of the
  6. -- Sather distribution. The license is also available from ICSI,
  7. -- 1947 Center St., Suite 600, Berkeley CA 94704, USA. 
  8. -------------------------------------------------------------------
  9. abstract class $RO_UGRAPH{NTP} < $GRAPH{NTP,UEDGE{NTP}} is
  10.    -- Undirected graphs. NTP indicates the type of the node index
  11.    -- which is used internally by a graph implementation to access
  12.    -- its
  13.    -- 
  14.    -- Since there is no valid subtyping relationship between ugraphs
  15.    -- and digraphs (neither is a proper subtype of the other) and due
  16.    -- to the subtle relationships between them, there is no subtyping
  17.    -- relationship between directed and undirected graphs.  We (will)
  18.    -- provide explicit conversion methods and adaptor "views" to see a
  19.    -- digraph as an undirected graph and vice versa
  20.  
  21.    copy: $RO_UGRAPH{NTP};
  22.    -- Return a copy of the graph
  23.    
  24.    equals(g: $RO_UGRAPH{NTP}): BOOL;
  25.    -- Return true if self = "g" i.e. if all the nodes and edges are equal 
  26.    -- (by is_eq)
  27.    
  28. end;
  29. -------------------------------------------------------------------
  30. abstract class $UGRAPH{NTP} < $RO_UGRAPH{NTP} is
  31.    -- A modifiable undirected graph. It has edges of type UEDGE{NTP},
  32.    -- which are simply unordered pairs of nodes
  33.    
  34.    add_node: NTP;
  35.    -- Add a node to the graph and return the node index, which is an
  36.    -- internal reference to the node (used within the graph implementation)
  37.    
  38.    add_node(n: NTP): NTP;
  39.    -- Add a node to the graph and return the new node index, which is an
  40.    -- internal reference to the node (used within the graph implementation)
  41.    -- The node that is returned may or may not be the same as the node
  42.    -- "n" that is passed in as an argument.
  43.  
  44.    connect(e: UEDGE{NTP});
  45.    -- Connect the nodes specified by edge "e". i.e. create an edge
  46.    -- between e.first and e.second
  47.    -- Usage: g: DIGRAPH{INT} := #;
  48.    --    n3 ::= g.add_node; 
  49.    --    n4 ::= g.add_node;
  50.    --    g.connect(#DIEDGE{INT}(n3,n4));
  51.    -- Note that UGRAPH_INCL has wrappers to allow you to write g.connect(n3,n4);
  52.    
  53.    delete_node(n: NTP);
  54.    -- Delete the node "n" from the graph, and any associated edges
  55.  
  56.    disconnect(e: UEDGE{NTP});
  57.    -- Remove the edge "e" from the graph, from between nodes 
  58.    -- e.first and e.second
  59.    
  60.  
  61. end;
  62. -------------------------------------------------------------------   
  63.  
  64.